<#-- Created by IntelliJ IDEA.
 User: qiguoqing
 Date: 2020/11/14
 Time: 11:06
 To change this template use File | Settings | File Templates.-->
<#-- 2020-12-16日改为字典设置页面 -->
<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>字典设置</title>
    <meta name="renderer" content="webkit">
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <#--   <link rel="stylesheet" href="${re.contextPath}/plugin/lay/layui/css/layui.css">-->
    <!--layui样式-->
    <link rel="stylesheet" href="${re.contextPath}/plugin/layui/css/layui.css" media="all"/>
    <!--公用样式-->
    <link rel="stylesheet" type="text/css" href="${re.contextPath}/plugin/common/css/comment.css"/>
    <!--页面样式-->
    <link rel="stylesheet" type="text/css" href="${re.contextPath}/plugin/common/css/style.css"/>
    <!--扩展样式-->
    <link rel="stylesheet" href="${re.contextPath}/plugin/common/css/extended.css">
    <link rel="stylesheet" href="${re.contextPath}/plugin/lenos/main.css">
    <script type="text/javascript" src="${re.contextPath}/plugin/jquery/jquery-3.2.1.min.js"></script>
    <script type="text/javascript" src="${re.contextPath}/plugin/layui/layui.all.js" charset="utf-8"></script>
    <#--    <script type="text/javascript" src="${re.contextPath}/plugin/lay/layui/layui.js"-->
    <#--            charset="utf-8"></script>-->
    <style>
        .project {
            margin-top: 20px;
            padding: 0px;

        }
    </style>
</head>
<body class="whitebg">
<div class="lenos-search"  style="padding: 10px 10px;">
    <div class="select">
        标题：
        <div class="layui-inline">
            <input class="layui-input" height="20px" id="title" autocomplete="off">
        </div>
        关键字：
        <div class="layui-inline">
            <input class="layui-input" height="20px" id="keyword" autocomplete="off">
        </div>
        <button class="select-on layui-btn layui-btn-sm" onclick="query()"><i class="layui-icon"></i>
        </button>
        <button class="layui-btn layui-btn-sm icon-position-button" id="refresh" onclick="reset()">
            <i class="layui-icon">ဂ</i>
        </button>
    </div>
</div>

</div>
<div class="layui-row">
    <div>
        <div style="padding: 10px 20px 0px 20px">
            <div class="layui-btn-container">
                <button class="layui-btn layui-btn-sm"  style="background-color: #1E9FFF;" onclick="add()">新增</button>
            </div>
            <table id="tableList" style="height: 230px;width:100%;margin-left: 2px" class="layui-hide"
                   lay-filter="tableList"
                   width="100%"></table>
        </div>
    </div>
</div>

<script type="text/javascript" src="${re.contextPath}/plugin/tools/tool.js"></script>
<script type="text/javascript" src="${re.contextPath}/plugin/tools/cardUtils.js"></script>


<script type="text/html" id="toolBarRow">
    <a class="layui-btn layui-btn-xs  layui-btn-normal" lay-event="detail" style="margin-left: 0px;">详情</a>
    <a class="layui-btn layui-btn-xs  layui-btn-normal" lay-event="edit" style="margin-left: 0px;">编辑</a>
    <a class="layui-btn layui-btn-xs  layui-btn-normal" lay-event="del" style="margin-left: 0px;">删除</a>
</script>

<script>
    var inC = 1;
    var layer;
    var form = layui.form;
    var table = null;
    var tableIns = null;
    document.onkeydown = function (e) { // 回车提交表单
        var theEvent = window.event || e;
        var code = theEvent.keyCode || theEvent.which;
        if (code == 13) {
            $(".select .select-on").click();
        }
    }

    var stageId = null;
    //注意进度条依赖 element 模块，否则无法进行正常渲染和功能性操作
    var element = "";
    layui.use('element', function () {
        element = layui.element;
    });
    layui.use('table', function () {
        table = layui.table;
        element = element;
        //方法级渲染
        tableIns = table.render({
            id: 'tableList',
            elem: '#tableList',
            height: 'full-20',
            url: '/sys/base/programManager/showList',
            cols: [[
                {
                    title: '序号', width: '15%', templet: function (res) {
                        return res.LAY_INDEX;
                    }
                },
                {field: 'programId', title: '编号', hide: true, sort: false},
                {field: 'title', title: '标题', width: '20%', sort: false},
                {field: 'keyword', title: '关键字', width: '20%', sort: false},
                {field: 'info', title: '图文信息', width: '20%', sort: false},
                {field: 'remark', title: '操作', width: '30%', toolbar: "#toolBarRow"}
            ]],
            page: true,
            done: function (res, currentCount) {

            }
        });
        table.on('tool(tableList)', function (obj) {
            var data = obj.data;
            if (obj.event === 'edit') {
                edit(data.programId);
            }
            if (obj.event === 'del') {
                del(data.programId);
            }
            if (obj.event === 'detail') {
                detail(data.programId);
            }



        });
        table.on('toolbar(tableList)', function (obj) {
            if (obj.event === 'add') {
                add();
            }
        })
    })


    function query() {
        var title = $('#title').val();
        var keyword = $('#keyword').val();
        var jsondata = {
            title: title,
            keyword: keyword
        };
        table.reload('tableList', {where: jsondata});
    }

    function reset() {
        $('#title').val("");
        $('#keyword').val("");
        var jsondata = {
            title: "",
            keyword: ""
        };
        table.reload('tableList', {where: jsondata});
    }

    function del(programId) {
        layer.confirm('确定删除吗？', function (index) {
            layerAjax('/sys/base/programManager/delete', {"programId": programId}, '', function (d) {
                if (d.flag == true) {
                    layui.table.reload('tableList');
                    layer.msg("操作成功", {icon: 1});
                } else {
                    layer.msg(d.msg, {icon: 1});
                }
            });
        });
    }

    function add() {
        var w = ($(window).width() * 0.9);
        var h = ($(window).height() - 50);
        layer.open({
            id: 'type-add',
            type: 2,
            area: [w + 'px', h + 'px'],
            fix: false,
            maxmin: true,
            shadeClose: false,
            shade: 0.4,
            title: "添加预案",
            content: '/sys/base/programManager/toadd',
            yes: function () {
            },
            btn2: function () {
                layer.closeAll();
            },
            zIndex: layer.zIndex, //重点1,
            success: function (layero) {
                layer.setTop(layero); //重点2
            },
            end: function () {
                tableIns.reload();
            }
        });
    }

    function edit(programId) {
        var w = ($(window).width() * 0.9);
        var h = ($(window).height() - 50);
        layer.open({
            id: 'type-add',
            type: 2,
            area: [w + 'px', h + 'px'],
            fix: false,
            maxmin: true,
            shadeClose: false,
            shade: 0.4,
            title: "修改预案",
            content: '/sys/base/programManager/toupdate?programId=' + programId,
            yes: function () {
            },
            btn2: function () {
                layer.closeAll();
            },
            zIndex: layer.zIndex, //重点1,
            success: function (layero) {
                layer.setTop(layero); //重点2
            },
            end: function () {
                tableIns.reload();
            }
        });
    }
    function detail(programId) {
        var w = ($(window).width() * 0.9);
        var h = ($(window).height() - 50);
        layer.open({
            id: 'type-add',
            type: 2,
            area: [w + 'px', h + 'px'],
            fix: false,
            maxmin: true,
            shadeClose: false,
            shade: 0.4,
            title: "预案信息",
            content: '/sys/base/programManager/detail?programId=' + programId,
            yes: function () {
            },
            btn2: function () {
                layer.closeAll();
            },
            zIndex: layer.zIndex, //重点1,
            success: function (layero) {
                layer.setTop(layero); //重点2
            },
            end: function () {
                tableIns.reload();
            }
        });
    }


</script>
</body>

</html>